﻿/*
 * This software is the confidential and proprietary
 * information of NetBay
 * Such confidential information should not be disclosed
 * NetBay copyright(c) 2010
 */

#region Using
using System;
using System.Runtime.Serialization;
using System.Text;
using System.ServiceModel.DomainServices.Server;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
#endregion
namespace NetBay.Core.BusinessEntities
{

    /// <summary>
    /// Class handle a Flow
    /// </summary>
    [DataContract]
    public class MessageFlow : ReturnObject
    {
        #region Enums
        #endregion

        #region Constants
        #endregion

        #region Private members
        /// <summary>
        /// 
        /// </summary>
        private long m_lIdentifier;

        /// <summary>
        /// 
        /// </summary>
        private User m_oEmetteur;

        /// <summary>
        /// 
        /// </summary>
        private string m_sObjet;

        /// <summary>
        /// 
        /// </summary>
        private DateTime m_dtExpedition;

        /// <summary>
        /// 
        /// </summary>
        private string m_sDestinataireList;

        /// <summary>
        /// 
        /// </summary>
        private string m_sDestinataire;

        /// <summary>
        /// 
        /// </summary>
        private long m_lGroupId;
                      
        /// <summary>
        /// 
        /// </summary>
        private string m_sMemo;

        /// <summary>
        /// User identifier in a group
        /// </summary>
        private long m_lrgu_id;

        /// <summary>
        /// 
        /// </summary>
        private List<Document> m_lMessageFlowDocuments;

        /// <summary>
        /// 
        /// </summary>
        private int m_iMyDocEtat;

        private string m_sChrono;

        private bool m_bSendAlertByEmail;

        #endregion

        #region Init/Constructor
        /// <summary>
        /// Default constructor 
        /// </summary>
        public MessageFlow()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Folder"/> class for error usages
        /// </summary>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="applicationException">The application exception.</param>
        public MessageFlow(string errorMessage, Exception applicationException = null)
            : base(errorMessage, applicationException)
        {
        }
        #endregion
        
        #region Properties

        [DataMember]
        public bool SendAlertByEmail
        {
            get { return m_bSendAlertByEmail; }
            set { m_bSendAlertByEmail = value; }
        }


        [DataMember]
        public long Identifier
        {
            get { return m_lIdentifier; }
            set { m_lIdentifier = value; }
        }

        [Association("Emetteur1", "ForeignKey1", "Key")]
        [Include]
        [DataMember]
        public User Emetteur
        {
            get { return m_oEmetteur; }
            set {
                ForeignKey1 = value.Key;
                m_oEmetteur = value; }
        }

        [Association("DocumentList", "Key", "ForeignKey")]
        [Include]
        [DataMember]
        public List<Document> DocumentList
        {
            get { return m_lMessageFlowDocuments; }
            set
            {
                m_lMessageFlowDocuments = value;
                ItemEntity.SetForeignKey(m_lMessageFlowDocuments, Key);
            }
        }

        [DataMember]
        public string DestinataireList
        {
            get { return m_sDestinataireList; }
            set { m_sDestinataireList = value; }
        }

        [DataMember]
        public string Destinataire
        {
            get { return m_sDestinataire; }
            set { m_sDestinataire = value; }
        }

        [DataMember]
        public long GroupId
        {
            get { return m_lGroupId; }
            set { m_lGroupId = value; }
        }

        [DataMember]
        public long RguId
        {
            get { return m_lrgu_id; }
            set { m_lrgu_id = value; }
        }

        [DataMember]
        public DateTime Expedition
        {
            get { return m_dtExpedition; }
            set { m_dtExpedition = value; }
        }
        
        [DataMember]
        public string Objet
        {
            get { return m_sObjet; }
            set { m_sObjet = value; }
        }
        
        [DataMember]
        public string Memo
        {
            get { return m_sMemo; }
            set { m_sMemo = value; }
        }

        [DataMember]
        public string Chrono
        {
            get { return m_sChrono; }
            set { m_sChrono = value; }
        }
        
        [DataMember]
        public int MyDocEtat
        {
            get { return m_iMyDocEtat; }
            set { m_iMyDocEtat = value; }
        }

        /// <summary>
        /// Get or set the last message read date
        /// </summary>
        private DateTime m_dtLastReadDate;
        [DataMember]
        public DateTime LastReadDate
        {
            get { return m_dtLastReadDate; }
            set
            {
                m_dtLastReadDate = value;
            }
        }

        /// <summary>
        /// Get or set the last message action date
        /// </summary>
        private DateTime m_dtLastActionDate;
        [DataMember]
        public DateTime LastActionDate
        {
            get { return m_dtLastActionDate; }
            set
            {
                m_dtLastActionDate = value;
            }
        }

        /// <summary>
        /// Get or set the last message action date
        /// </summary>
        private String m_sFolderUrl;
        [DataMember]
        public String FolderURL
        {
            get { return m_sFolderUrl; }
            set
            {
                m_sFolderUrl = value;
            }
        }
        
        #region ToString
        /// <summary>
        /// Extend default description of class
        /// </summary>
        /// <returns>description of instance</returns>
        public override string ToString()
        {
            StringBuilder parameters = new StringBuilder("Identifier<", 4096);
            parameters.Append(Identifier); parameters.Append("> ");
            return parameters.ToString();
        }

        #endregion

        #endregion
    }

    public abstract class MessageFlowDer : MessageFlow
    {

    }
}
